package org.ws.edu.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.apache.log4j.Logger;

public class Test implements Serializable, Cloneable {
    private static Logger logger = Logger.getLogger(Test.class);
    private String name = null;
    private Type type = null;
    private List<Question> questions = null;
    private HashMap<Integer, String> result = null;

    public Test() {

    }

    @Override
    public Test clone() {
        Test t = null;
        try {
            t = (Test) super.clone();
            t.questions = new ArrayList<Question>(this.questions);
            if (type == Type.SCALES) {
                t.result = new HashMap<Integer, String>(this.result);
            }
        } catch (CloneNotSupportedException e) {
            logger.warn("Not supported clone", e);
        }
        return t;
    }

    public void setName(String name) {
        this.name = name;
    }

    public HashMap<Integer, String> getResult() {
        return result;
    }

    public void setResult(HashMap<Integer, String> result) {
        this.result = result;
    }

    public void setType(Type type) {
        this.type = type;
    }

    public void setQuestions(List<Question> questions) {
        this.questions = questions;
    }

    public String getName() {
        return name;
    }

    public Type getType() {
        return type;
    }

    public List<Question> getQuestions() {
        return questions;
    }

    @Override
    public String toString() {
        return "Test [name=" + name + ", type=" + type + ", questions=" + questions + "]" + " result " + result;
    }

    @Override
    public boolean equals(Object obj) {
        Test ans = (Test) obj;
        if ((this.getName().equals(ans.getName())) && ((this.getQuestions().equals(ans.getQuestions())))) {
            return true;
        }
        return false;

    }
    
}
